
let ms = require('m-service');

module.exports = (options, app) => {
    return async function xsoaHandler(ctx, next) {
        if (options.enable && options.enable === true) {
            ms.createApp({
                centers: options.center, //指定注册服务中心      
                services: { //启动服务
                    port: app.config.cluster.listen.port,
                    dir: __dirname,
                    names: [options.localServerName],
                }
            });
            await next(options);
        } else {
            await next(options);
        }
    };

};